<?php
namespace app\api\controller;
use app\common\BaseController;

use think\Db;
class InsureReceivable extends BaseController{
    public function __construct(){
        parent::__construct();       
    }
    public function index(){        
        $params = $this->request->param();
        if(!isset($params['date_type']) || $params['date_type']="begdate"){
            $date_type="begdate";
        }else{
            $date_type="insurance_date";
        }
        $balance=0;
        $dates=Db::table('lt_policy')
        ->field("{$date_type} as date,count(*) as num,sum(premium) as total")        
        ->group("{$date_type}")
        ->order("{$date_type} desc")
        ->select();
        
        
        return $dates;
    }
   
}
